package base;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

public class BaseDriver {
	
	public AndroidDriver<AndroidElement> driver = null;
	String url_base = "http://127.0.0.1:4723/wd/hub";
	//com.cnezsoft.xxm/.MainActivity
	@BeforeClass
	public void initApp() throws MalformedURLException {
		URL url = new URL(url_base);
		DesiredCapabilities capabilities = new DesiredCapabilities();
		
		capabilities.setCapability("platformName", "Android");
		capabilities.setCapability("desviceName", "127.0.0.1:52001");
		capabilities.setCapability("appPackage", "com.cnezsoft.xxm");
		capabilities.setCapability("appActivity", ".MainActivity");
		
		driver = new AndroidDriver<AndroidElement>(url,capabilities);
		
	}
	
	@AfterMethod
	public void quitApp() {
		if(driver !=null) {
			driver.quit();
		}
	}

}
